// 别人日记界面

let btn_n = document.querySelector('.btn_n')
let diarys = document.querySelector('.diarys')
let year = document.querySelector('.ss') //年
let month = document.querySelector('.title-date span') // 月
let date = document.querySelector('.title-date b') // 日

// console.log(year);

btn_n.onclick = function () {
    var btn_n = document.body.scrollTop || document.documentElement.scrollTop
    scrollBy(0, -btn_n);
}

let newDate = new Date();
let year1 = newDate.getFullYear(), //年

    month1 = newDate.getMonth() + 1, //月

    date1 = newDate.getDate(), //日

    h = newDate.getHours(),

    m = newDate.getMinutes(),

    s = newDate.getSeconds(),

    day1 = newDate.getDay(),

    week = ["星期日", "星期一", "星期二", "星期三", "星期四", "星期五", "星期六"]


// console.log(year1, month1, date1, day1);

function data_data() {
    let html = ''

    html = `
        <div class="sidebar-item title-date">
        ${month1}/${date1}
        <span>/${year1}</span>
        <b>${week[day1]}</b>
         </div>
        `
    year.innerHTML = html
}
data_data()

async function diarya() {
    let html = ''
    let authorId
    let res = await axios({
        method: 'GET',
        url: '/api/diaryItem/homepage',
        params: {
            limit: 1,
            offset: 0,
        }
    })
    // userId
    // token 
    // console.log(res);

    let date_d = res.data.data

    console.log(date_d);

    date_d.forEach(item => {
        // console.log(item.createAt);
        // console.log(h, m);
        html += `
    <div class="diary">
    <div class="body body-no-icon">
        <div class="title">
            ${h} : ${m} am <a class="book" href="#">《过日子》</a>
        </div>
        <pre class="content">
 ${item.content}
<img class="emojione" alt="😝" src=" "><img class="emojione" alt="😝" src=" ">
</pre>
        <div class="bottom">
            <a class="a" href="#">回复</a>
        </div>
    </div>
</div>
`
    })

    diarys.innerHTML = html

    let aa = document.querySelectorAll('.a')
    // console.log(aa);
    aa.forEach((item) => {
        item.onclick = function () {

            console.log(1);

            window.location.href = '../../html/ys/reply.html'

        }
    })

}

diarya()